<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>compute / method </title>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
</head>
<body>
<div id="example">
    <p>Original message: "{{ message }}"</p>
    <p>Computed reversed message: "{{ reversedMessage }}"</p>
    <p>Reversed method: "{{ reverseMethod() }}"</p>
</div>


<script>

    var vm = new Vue({
        el: '#example',
        data: {
            message: 'Hello'
        },
        computed: {
            // a computed getter
            reversedMessage: function () {
                // `this` points to the vm instance
                return this.message.split('').reverse().join('')
            }
        },
        methods: {
            reverseMethod: function () {
                return this.message.split('').reverse().join('')
            }
        }
    })

</script>
</body>
</html>
